#ifndef VARIANTDLLAPI_H
#define VARIANTDLLAPI_H

#include <QSettings>
#include <QString>

#ifdef COMMONBASE_LIB
# define COMMONBASE_EXPORT Q_DECL_EXPORT
#else
# define COMMONBASE_EXPORT Q_DECL_IMPORT
#endif


class COMMONBASE_EXPORT QConfigFile
{
public:
	QConfigFile(QString filepath);
	~QConfigFile();

	bool	checkConfigFile(QString title,QString header); 

	template <typename T>
	void	writeConfigFile(QString title,QString header,T qvalue);

	template <typename T>
	void	readConfigFile(QString title,QString header,T& qvalue);
private:
	QSettings*		m_settings;
};

template <typename T>
void QConfigFile::writeConfigFile(QString title, QString header,T value )
{
	QVariant qvalue(value);
	m_settings->beginGroup(title);
	m_settings->setValue(header,qvalue);
	m_settings->endGroup();
}

template <typename T>
void QConfigFile::readConfigFile( QString title,QString header,T& value )
{
	m_settings->beginGroup(title);
	value = m_settings->value(header).value<T>();
	m_settings->endGroup();
}



#ifndef COMMONBASE_LIB
#pragma comment(lib,"CommonBase.lib")
#endif

#endif // VARIANTDLLAPI_H
